﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Yunchang;

namespace AutoChess
{
    public enum HeroBehaviourState
    {
        None,
        Idle,
        Jump,
        ShowUp,
        Show
    }
    public enum JumpType
    {
        Forward,
        Back,
    }
    public class JumpPakage
    {
        public JumpType jumpType;
        public Vector3 targetPos;
        public Action callEnd;
        public float jumpTime = 1;
        public JumpPakage(Vector3 targetPos ,JumpType jumpType,Action callEnd)
        {
            this.jumpType = jumpType;
            this.targetPos = targetPos;
            this.callEnd = callEnd;
        }
    }
    public class ShowUpPakage
    {
        public Action callEnd;
        public ShowUpPakage(Action callEnd)
        {
            this.callEnd = callEnd;
        }
    }
    public class ShowPackage
    {
        public Action callEnd;
        public string animName;
        public ShowPackage(string animName, Action callEnd)
        {
            this.callEnd = callEnd;
            this.animName = animName;
        }
    }
    public class HeroBehaviourCtr : FsmControllerBase<HeroBehaviourState>
    {
       // public HeroUnitRenderer heroRenderer;

        public JumpPakage jumpData;
        public ShowUpPakage showUpData;
        public ShowPackage showData;

        public HeroBehaviourCtr(HeroUnitRenderer heroRenderer)
        {
            this.heroRenderer = heroRenderer;
            InitState();
        }
        public override void InitState()
        {
            base.InitState();
            allStates[HeroBehaviourState.None] = new HeroNone(HeroBehaviourState.None,this);
            allStates[HeroBehaviourState.Idle] = new HeroIdelState(HeroBehaviourState.Idle, this);
            allStates[HeroBehaviourState.Jump] = new HeroJumpState(HeroBehaviourState.Jump, this);
            allStates[HeroBehaviourState.ShowUp] = new HeroShowUpState(HeroBehaviourState.ShowUp, this);
            allStates[HeroBehaviourState.Show] = new HeroShowState(HeroBehaviourState.Show, this);
        }

        public void JumpToPosition(JumpPakage args)
        {
            jumpData = args;
            SwitchState(HeroBehaviourState.Jump);
        }

        public void ShowUp(ShowUpPakage args)
        {
            showUpData = args;
            SwitchState(HeroBehaviourState.ShowUp);
        }

        public void Show(ShowPackage args)
        {
            showData = args;
            SwitchState(HeroBehaviourState.Show);
        }
    }
}